home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-09-11 | 10.2 KB | 253 lines | [TEXT/MPS ] |
- Instructions - The C++ Examples
-
- Copyright Apple Computer, Inc. 1987, 1988
- All rights reserved.
-
-
- About the Examples
-
- Three sample C++ programs are included with MPW C: two applications,
- and a tool:
-
- CPlusShapesApp - a simple MultiFinder-Aware Sample application
- CPlusTESample - a simple MultiFinder-Aware TextEdit application
- Count - an MPW tool
-
- The source files for each of these examples are in the
- "Examples:CPlusExamples:" folder. In addition, the makefiles
- containing the commands needed to build each of the
- examples are provided in the same folder.
-
- NOTE: Due to the larger memory requirements of CFront, you will need
- to set the memory partition of the MPW Shell to at least 2Mb
- before attempting to build CPlusShapesApp or CPlusTESample.
-
-
- Building the Examples
-
- You can easily build each of the sample programs using the Directory
- and Build menus. (See Chapter 2 of the MPW Reference.)
-
- Set the default directory to "CPlusExamples:"
-
- The simplest way to do this is to execute the following command
-
- Directory "{MPW}"Examples:CPlusExamples:
-
-
- Build the program
-
- You can use any of the four Build items at the bottom of the Build
- menu to build the program you have selected. Each of these menu
- items displays a dialog box that asks for the name of the program
- you want to build. When this dialog box appears, type the name of
- one of the sample programs (CPlusShapesApp, CPlusTESample, or Count).
-
- Each of the Build menu items behaves slightly differently:
-
- Build… - The program is automatically built. The commands
- used, and any error messages, are displayed in the Worksheet.
- Only files that have been changed since you last built the
- program are compiled, saving considerable time.
-
- Full Build… - The program is completely rebuilt, ignoring
- any object files or intermediate files that may already exist
- from a previous build. The commands used, and any errors, are
- displayed in the Worksheet.
-
- Show Build Commands… - The commands needed to build the program
- are written to the Worksheet, but not executed. You can then
- select any or all of the commands and execute them yourself.
- (To execute the commands select them and press Enter.)
-
- Show Full Build Commands… - The commands needed to completely
- rebuild the program are written to the Worksheet. This is a
- convenient way to see all of the commands used in building
- the program you have selected.
-
-
- Note: For more information about building the sample programs, see
- Chapter 2 of the MPW Reference.
-
-
-
- CPlusShapesApp - A Simple MultiFinder-Aware Sample Application
-
- CPlusShapesApp is an example application that demonstrates how to
- initialize the commonly used toolbox managers, operate successfully
- under MultiFinder, handle desk accessories and draw simple shapes.
-
- CPlusShapesApp is based on a crude application framework comprised in
- the two classes TApplication and TDocument. These classes together
- define a basic framework for Mac applications, without having any
- specific knowledge about the type of data being displayed by the
- application's documents. They are a (very) crude implementation of
- the MacApp application model, without the sophisticated view heirarchies
- or any real error handling.
-
- The TApplication class does all of the basic event handling
- and initialization necessary for Mac Toolbox applications.
- It maintains a list of TDocument objects, and passes events
- to the correct TDocument class when apropriate.
-
- The TDocument class does all of the basic document handling
- work. TDocuments are objects that are associated with a
- window. Methods are provided to deal with update, activate,
- mouse-click, key down, and other events. Some additional
- classes which implement a linked list of TDocument objects
- are provided.
-
- The source for the application library is contained in the files
- TApplication.h, TApplicationCommon.h, TApplication.cp, TDocument.h,
- and TDocument.cp. Resource descriptions are contained in the files
- TApplicationCommon.h and TApplication.r.
-
- CPlusShapesApp itself is composed of three classes TShapesApp,
- TShapesDocument and a TShapes hierarchy for drawing the individual
- shapes.
-
- The TShapesApp class is a subclass of TApplication. It
- overrides several TApplication methods, including those
- for handling menu commands and cursor adjustment, and
- it does some necessary initialization.
-
- The TShapesDocument class is a subclass of TDocument. This
- class contains most of the special purpose code for
- shape drawing. In addition to overriding several of the
- TDocument methods, it defines a few additional
- methods which are used by the TShapesApp class to get
- information on the document state.
-
- The source is contained in the files ShapesApp.h, ShapesAppCommon.h,
- ShapesApp.cp, ShapesDocument.h, ShapesDocument.cp, Shapes.h and Shapes.cp.
- Resource descriptions are contained in the files ShapesAppCommon.h and
- ShapesApp.r. The make dependency file is named CPlusShapesApp.make.
-
- To build CPlusShapesApp, simply select the line below and press Enter.
-
- BuildProgram CPlusShapesApp ∑∑ {Worksheet}
-
- To execute CPlusShapesApp, select the line below and press Enter.
-
- CPlusShapesApp
-
-
-
- TESample - A Simple MultiFinder-Aware TextEdit Application
-
- CPlusTESample is an example application that demonstrates how to
- initialize the commonly used toolbox managers, operate successfully
- under MultiFinder, handle desk accessories and create, grow, and zoom
- windows. The fundamental TextEdit toolbox calls and TextEdit
- autoscroll are demonstrated. CPlusTESample also shows how to create
- and maintain scrollbar controls.
-
- CPlusTESample is based on a crude application framework comprised in
- the two classes TApplication and TDocument. These classes together
- define a basic framework for Mac applications, without having any
- specific knowledge about the type of data being displayed by the
- application's documents. They are a (very) crude implementation of
- the MacApp application model, without the sophisticated view heirarchies
- or any real error handling.
-
- The TApplication class does all of the basic event handling
- and initialization necessary for Mac Toolbox applications.
- It maintains a list of TDocument objects, and passes events
- to the correct TDocument class when apropriate.
-
- The TDocument class does all of the basic document handling
- work. TDocuments are objects that are associated with a
- window. Methods are provided to deal with update, activate,
- mouse-click, key down, and other events. Some additional
- classes which implement a linked list of TDocument objects
- are provided.
-
- The source for the application library is contained in the files
- TApplication.h, TApplicationCommon.h, TApplication.cp, TDocument.h,
- and TDocument.cp. Resource descriptions are contained in the files
- TApplicationCommon.h and TApplication.r.
-
- CPlusTESample itself is composed of three classes TESample,
- and TEDocument, both derived from the application framework classes
- described above.
-
- The TESample class is a subclass of TApplication. It
- overrides several TApplication methods, including those for
- handling menu commands and cursor adjustment, and it does
- some necessary initialization. Note that we only need to
- override
-
- The TEDocument class is a subclass of TDocument. This class
- contains most of the special purpose code for text editing.
- In addition to overriding most of the TDocument methods, it
- defines a number of additional methods which are used by
- the TESample class to get information on the document
- state.
-
- The source is contained in the files TESample.h, TECommon.h,
- TESample.cp, TESampleGlue.a, TEDocument.h, and TEDocument.cp.
- Resource descriptions are contained in the files TECommon.h and
- TESample.r. The make dependency file is named CPlusTESample.make.
-
- To build CPlusTESample, simply select the line below and press Enter.
-
- BuildProgram CPlusTESample ∑∑ {Worksheet}
-
- To execute CPlusTESample, select the line below and press Enter.
-
- CPlusTESample
-
-
-
- Count - A Sample MPW Tool
-
- Count, a tool that runs in the MPW environment, counts characters and
- lines in files. A C version of Count is included with MPW, and is
- documented in the MPW Reference, Part II. The source for Count is in
- the files Count.cp, StreamCounter.h, and StreamCounter.cp and Count.r.
-
- Count is composed of two classes TCountTool and TStreamCounter.
- TCountTool embodies the control flow of the tool, while TStreamCounter
- contains a generic line/character counter for C++ streams.
-
- To build Count, simply select the line below and press Enter.
-
- BuildProgram Count ∑∑ {Worksheet}
-
- To test Count, try counting the characters in file Count.cp.
-
- Count -c Count.cp
-
-
-
- Writing Your Own Programs
-
- After building (and perhaps modifying) the sample programs, you will
- undoubtedly want to write a program of your own. Use the New… item in
- the File menu, to create the source files. Remember that C language
- source filenames should end in .c.
-
- Create Build Commands… - The Create Build Commands… item in the
- Build menu runs a script that creates a makefile containing the
- commands for building programs written in C, C++, Assembly Language, Pascal,
- and/or Rez. Selecting Create Build Commands… displays a dialog box that
- allows you to enter information about your program. Type the program's
- name, select its source files by clicking the Files… button, and click
- one of the radio buttons to indicate your choice of an application, tool,
- or desk accessory.
-
- Create Build Commands… puts the makefile for your program in the file
- <program>.make. Now you can use the Build menu to build and rebuild
- your program, just as with the examples.
-
- Larger Programs - If you add source files as your program grows,
- use Create Build Commands… again to add the new source files to the build
- instructions. If you out-grow the capabilities of the simple Create
- Build Commands… script (perhaps by using tools other than Asm, C, C++,
- Pascal, Rez, and Link in your builds) you can modify the makefile yourself.
-
- Modifying the Directory and Build Menus - The Directory and Build
- menus are both implemented using scripts written in the MPW Shell
- command language. This has the big advantage that you can modify
- or customize them to match the way you work.
-